﻿namespace Expression
{
    using Interface;
    /// <summary>
    /// 用户输入参数
    /// </summary>
    public class ArgUser : IArg, IArgConverter
    {
        /// <summary>
        /// 参数名称
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 参数展示名称
        /// </summary>
        public string Display { get; set; }
        /// <summary>
        /// 参数类型:double/int/long/string/datetime/point
        /// </summary>
        public string DataType { get; set; }

        /// <summary>
        /// 参数值得
        /// </summary>
        public object Value { get; set; }

       
        /// <summary>
        /// 
        /// </summary>
        /// <param name="arg"></param>
        /// <param name="exp"></param>
        public void Converter(IArg arg, IAlgorithmBehaviours exp)
        {
            if (arg is ArgUser)
            {
                ArgUser argUser = arg as ArgUser;
                switch (argUser.DataType.ToLower())
                {
                    case "double":
                        {
                            new ArgDouble().Converter(argUser, exp);
                        }
                        break;
                    case "int":
                        {
                            new ArgInt().Converter(argUser, exp);
                        }
                        break;
                    case "long":
                        {
                            new ArgLong().Converter(argUser, exp);
                        }
                        break;
                    case "string":
                        {
                            new ArgString().Converter(argUser, exp);
                        }
                        break;
                    case "datetime":
                        {
                            new ArgDateTime().Converter(argUser, exp);
                        }
                        break;
                    case "point":
                        {
                            new ArgPoint().Converter(argUser, exp);
                        }
                        break;
                    default:
                        {
                            new ArgString().Converter(argUser, exp);
                        }
                        break;
                }
            }

        }
    }

}
